﻿Import-Module -Force ..\ConfigurationDatabase\libConfigurationDatabase.psm1
Import-Module -Force .\libSQLServerStatistics.psm1

$servers=Get-Content .\SQLServers.txt

$scriptEnvironmentShortName="QA6"
$samplingIntervalInMinutes=15

while($true)
{
    foreach($server in $servers)
    {
        Write-Host "Getting detailed buffer distribution stats for $server"
        $bufferDistributionMeasurements=Get-SQLDetailedBufferDistributionStatisticsSample -serverName $server

        Store-SQLDetailedBufferDistributionStatisticsSample -environmentShortName $scriptEnvironmentShortName -bufferDistributionMeasurements $bufferDistributionMeasurements
    }
    Write-Host "Waiting for next sampling. Now is the time to interrupt!"
    Start-Sleep -Seconds ($samplingIntervalInMinutes*60)
}